<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="教育程度" prop="education">
        <el-select v-model="queryParams.education" placeholder="请选择教育程度" clearable>
          <el-option v-for="dict in dict.type.hr_education" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="电话" prop="phone">
        <el-input v-model="queryParams.phone" placeholder="请输入电话" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="queryParams.email" placeholder="请输入邮箱" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="应聘岗位" prop="job">
        <el-select v-model="queryParams.job" placeholder="请选择应聘岗位" clearable>
          <el-option v-for="dict in dict.type.hr_job" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="简历来源" prop="source">
        <el-select v-model="queryParams.source" placeholder="请选择简历来源" clearable>
          <el-option v-for="dict in dict.type.hr_resume_from" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="招聘地区" prop="area">
        <el-select v-model="queryParams.area" placeholder="请选择招聘地区" clearable>
          <el-option v-for="dict in dict.type.hr_area" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>


    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="success" plain size="mini" @click="handleRefresh">刷新</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['hr:resume:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['hr:resume:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['hr:resume:remove']">删除</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['hr:resume:export']">导出</el-button>
      </el-col> -->
      <!-- 如下这些按钮都是需要有对简历数据进行编辑的权限的, 或者之后划分更细一点也行 -->
      <el-col :span="1.5">
        <el-button v-if="type == 1" type="warning" plain size="mini" @click="clickCheck1" :disabled="multiple"
          v-hasPermi="['hr:resume:resumeCheck']">简历审核</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="type == 1" type="warning" plain size="mini" @click="clickCheck2" :disabled="multiple"
          v-hasPermi="['hr:resume:resumeCheck']">录用审核</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="type == 0" type="warning" plain size="mini" @click="handleFailurePosition" :disabled="multiple"
          v-hasPermi="['hr:resume:nouse']">无效</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="type == 2" type="warning" plain size="mini" @click="handleAbilityPosition" :disabled="multiple"
          v-hasPermi="['hr:resume:addAbility']">备用</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="type == 2" type="warning" plain size="mini" @click="clickDispatch" :disabled="multiple"
          v-hasPermi="['hr:resume:dispatch']">分配</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="type == 3" type="warning" plain size="mini" @click="cancelInduction" :disabled="multiple"
          v-hasPermi="['hr:resume:hire']">取消入职</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="type == 3" type="warning" plain size="mini" @click="doInduction" :disabled="multiple"
          v-hasPermi="['hr:resume:hire']">入职</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="type == 3" type="warning" plain size="mini" @click="handleSendOffer" :disabled="multiple"
          v-hasPermi="['hr:resume:sendOffer']">发送offer</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-if="type == 0 || type == 1 || type == 2 || type == 3 || type == 4" type="warning" plain size="mini"
          @click="handleBlackPosition" :disabled="multiple">
          加入黑名单
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="resumeList" @selection-change="handleSelectionChange" @row-click="rowClick">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="状态" align="center" prop="statusStr">
        <template slot-scope="scope">
          <el-tag class="custom-tag-size" size="small">
            {{ scope.row.statusStr }} <!-- 这里直接显示resumeCheck数组中的每个元素 -->
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="简历" align="center" prop="resumeUrl">
        <template slot-scope="scope">
          <!-- {{ scope.row.resumeUrl }} -->
          <pdf-viewer :srcList="[scope.row.resumeUrl]" style="width: 150px; height: 100px">
            <!-- <pdf-viewer :srcList="[test]" style="width: 150px; height: 100px"> -->
          </pdf-viewer>
        </template>
      </el-table-column>

      <el-table-column label="教育程度" align="center" prop="education">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.hr_education" :value="scope.row.education" />
        </template>
      </el-table-column>
      <el-table-column label="电话" align="center" prop="phone" />
      <el-table-column label="邮箱" align="center" prop="email" />
      <el-table-column label="应聘岗位" align="center" prop="job">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.hr_job" :value="scope.row.job" />
        </template>
      </el-table-column>
      <el-table-column label="简历来源" align="center" prop="source">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.hr_resume_from" :value="scope.row.source" />
        </template>
      </el-table-column>
      <el-table-column label="来源备注" align="center" prop="sourceRemarks" />
      <el-table-column label="招聘地区" align="center" prop="area">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.hr_area" :value="scope.row.area" />
        </template>
      </el-table-column>
      <!-- <el-table-column label="简历预览" align="center" prop="resumeUrl" /> -->
      <el-table-column label="备注说明" align="center" prop="remarks" />
      <el-table-column label="简历审核" align="center" prop="resumeCheck">
        <template slot-scope="scope">
          <el-tag class="custom-tag-size" v-for="(check, index) in scope.row.resumeCheck" :key="index">
            {{ check }} <!-- 这里直接显示resumeCheck数组中的每个元素 -->
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="录用审核" align="center" prop="hireCheck">
        <template slot-scope="scope">
          <el-tag class="custom-tag-size" v-for="(check, index) in scope.row.hireCheck" :key="index">
            {{ check }} <!-- 这里直接显示resumeCheck数组中的每个元素 -->
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="背调状态" align="center" prop="bgCheck">
        <template slot-scope="scope">
          <pdf-viewer :srcList="[scope.row.bgFile]" style="width: 150px; height: 100px"
            v-if="getBgStatus(scope.row.status) >= 2">
          </pdf-viewer>
          <el-button v-else size="mini" type="text" @click="clickBgCheck($event, scope.row)"
            v-hasPermi="['hr:resume:bg']">
            {{ scope.row.bgCheck }}</el-button>
          <!-- <el-button size="mini" type="text" @click="clickBgCheck($event, scope.row)" v-hasPermi="['hr:resume:bg']">
            {{scope.row.bgCheck }}</el-button> -->

        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改时间" align="center" prop="updateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['hr:resume:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['hr:resume:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改HR简历对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" />
        </el-form-item>

        <el-form-item label="教育程度" prop="education">
          <el-select v-model="form.education" placeholder="请选择教育程度">
            <el-option v-for="dict in dict.type.hr_education" :key="dict.value" :label="dict.label"
              :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="电话" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入电话" />
        </el-form-item>
        <el-form-item label="邮箱" prop="email">
          <el-input v-model="form.email" placeholder="请输入邮箱" />
        </el-form-item>
        <el-form-item label="应聘岗位" prop="job">
          <el-select v-model="form.job" placeholder="请选择应聘岗位">
            <el-option v-for="dict in dict.type.hr_job" :key="dict.value" :label="dict.label"
              :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核" prop="ruserIds">
          <el-select v-model="form.ruserIds" multiple collapse-tags style="margin-left: 20px;" placeholder="请选择">
            <el-option v-for="item in userList" :key="item.userId" :label="item.userName" :value="item.userId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="简历来源" prop="source">
          <el-select v-model="form.source" placeholder="请选择简历来源">
            <el-option v-for="dict in dict.type.hr_resume_from" :key="dict.value" :label="dict.label"
              :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="简历来源备注" prop="sourceRemarks">
          <el-input v-model="form.sourceRemarks" placeholder="请输入简历来源备注" />
        </el-form-item>
        <el-form-item label="招聘地区" prop="area">
          <el-select v-model="form.area" placeholder="请选择招聘地区">
            <el-option v-for="dict in dict.type.hr_area" :key="dict.value" :label="dict.label"
              :value="dict.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="简历上传" prop="resumeUrl">
          <file-upload v-model="form.resumeUrl" />
        </el-form-item>
        <el-form-item label="备注说明" prop="remarks">
          <el-input v-model="form.remarks" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 审核对话框 -->
    <el-dialog :title="checkTitle" :visible.sync="dialogCheckVisible">
      <el-form :model="checkForm">
        <el-form-item label="审核状态" label-width="80px">
          <el-select v-model="checkForm.status" placeholder="请选择">
            <el-option label="通过" value="1"></el-option>
            <el-option label="驳回" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核意见" label-width="80px">
          <el-input v-model="checkForm.advice" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelCheck">取 消</el-button>
        <el-button type="primary" @click="handleCheckForm">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 分配对话框 -->
    <!-- 审核对话框 -->
    <el-dialog title="分配" :visible.sync="dialogDispatchVisible">
      <el-form :model="dispatchForm">
        <el-form-item label="指定录用审核人员" label-width="80px">
          <el-select v-model="dispatchForm.userIds" multiple collapse-tags style="margin-left: 20px;" placeholder="请选择">
            <el-option v-for="item in userList" :key="item.userId" :label="item.userName" :value="item.userId">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelDispatch">取 消</el-button>
        <el-button type="primary" @click="handleDispatchForm">确 定</el-button>
      </div>
    </el-dialog>


    <el-dialog title="提交背调材料" :visible.sync="dialogbgSubmitVisible">
      <el-form :model="bgForm">
        <el-form-item label="背调材料上传">
          <file-upload v-model="bgForm.bgUrl" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelBgSubmit">取 消</el-button>
        <el-button type="primary" @click="handleBgSubmitForm">确 定</el-button>
      </div>
    </el-dialog>

    <div>
      <el-timeline>
        <el-timeline-item v-for="(item, index) in logList" :key="index" :timestamp="item.time" placement="top">
          <el-card class="timeline-card">
            <!-- 操作类型使用内联样式设置为主要大小和颜色（这里假设为主要颜色，不是淡蓝色） -->
            <p><span style="font-size: 16px; font-weight: bold;">操作类型:</span> {{ item.type }}</p>
            <!-- 其他内容使用CSS类设置为淡蓝色和稍小的字体大小 -->
            <p class="subtle-text"><strong>操作人:</strong> {{ item.operator }}</p>
            <p class="subtle-text"><strong>操作内容:</strong> {{ item.content }}</p>
            <p v-if="item.advice != null || item.advice !== ''" class="subtle-text">
              <strong>审核意见:</strong> {{ item.advice }}
            </p>
            <p v-if="item.supplement != null || item.supplement !== ''" class="subtle-text">
              <strong>补充内容:</strong> {{ item.supplement }}
            </p>
          </el-card>
        </el-timeline-item>
      </el-timeline>
    </div>


  </div>
</template>

<script>
import { listResume, getResume, delResume, addResume, updateResume, addAbility, addBlack, addFailure, doCheck, doDispatch, cancelInduction } from "@/api/hr/resume";
import { easyListUser } from "../../../../api/system/user";
import { getLog } from "../../../../api/hr/operationLog";
import { doInduction, sendOffer } from "../../../../api/hr/resume";
import { bgCheckStart, bgCheckSubmit } from "../../../../api/hr/bgCheck";
import pdfViewer from './viewIndex.vue'
import pdf from 'vue-pdf'
export default {
  name: "Resume",
  dicts: ['hr_education', 'hr_job', 'hr_check_status', 'hr_resume_from', 'hr_background_status', 'hr_area', 'hr_check_method'],
  components: {
    pdfViewer,
    pdf
  },
  data() {
    return {
      // test: "",
      resumePrevUrl: null,
      dialogbgSubmitVisible: false,
      bgForm: {
        bgUrl: null,
        resumeId: null,
      },
      checkType: 0,
      dialogCheckVisible: false,
      dialogDispatchVisible: false,
      isshowpdf: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // HR简历表格数据
      resumeList: [],
      // 弹出层标题
      title: "",
      checkTitle: "",
      // 是否显示弹出层
      open: false,
      // 用户列表
      userList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        education: null,
        phone: null,
        email: null,
        job: null,
        ruserIds: null,
        source: null,
        area: null,
        resumeUrl: null,
        remarks: null,
        status: null,
        backgroundStatus: null,
        resumeEvaluator: null,
        queryType: 0,
      },
      logList: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        name: [
          { required: true, message: "姓名不能为空", trigger: "blur" }
        ],
        education: [
          { required: true, message: "教育程度不能为空", trigger: "change" }
        ],
        phone: [
          { required: true, message: "电话不能为空", trigger: "blur" }
        ],
        email: [
          { required: true, message: "邮箱不能为空", trigger: "blur" }
        ],
        job: [
          { required: true, message: "应聘岗位不能为空", trigger: "change" }
        ],
        ruserIds: [
          { required: true, message: "审核员不能为空", trigger: "change" }
        ],
        source: [
          { required: true, message: "简历来源不能为空", trigger: "change" }
        ],
        area: [
          { required: true, message: "招聘地区不能为空", trigger: "change" }
        ],
        resumeUrl: [
          { required: true, message: "简历URL地址不能为空", trigger: "blur" }
        ],
        createTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
        updateTime: [
          { required: true, message: "修改时间不能为空", trigger: "blur" }
        ],
        backgroundStatus: [
          { required: true, message: "背景调查状态不能为空", trigger: "change" }
        ],
        inputUser: [
          { required: true, message: "简历录入人不能为空", trigger: "blur" }
        ],
        resumeEvaluator: [
          { required: true, message: "简历审核人不能为空", trigger: "blur" }
        ],
        hiringApprover: [
          { required: true, message: "录用审核人不能为空", trigger: "blur" }
        ]
      },
      checkForm: {
        status: null,
        advice: null,
        checkType: null,
        resumeIds: null,
      },
      dispatchForm: {
        userIds: null,
        resumeIds: null,
      },
    };
  },
  props: {
    type: {
      type: String,
      default: "1"
    },
  },
  created() {
    this.getList();
    console.log("当前类型: ", this.$props.type);

  },
  watch: {
    // 监听type的变化
    type(newVal, oldVal) {
      // 当type变化时，调用你的方法
      this.getList();
      this.logList = [];
    }
  },
  methods: {
    bgFormReset() {
      this.bgForm = {
        bgUrl: null,
        resumeId: null,
      }
    },
    /**
     * 某一行被点击
     */
    rowClick(row, column, event) {
      console.log("点击了某一行", row);
      getLog(row.id).then(response => {
        this.logList = response.data;
      })
    },

    /**
     * 获取用户列表
     */
    getUserList() {
      easyListUser().then(response => {
        this.userList = response.data;
      });
    },

    /**
     * 页面 刷新
     */
    handleRefresh() {
      // 重新获取一下数据
      this.getList();
    },

    /**
     * pdf  相关的三个方法
     */
    closepdf() {
      this.isshowpdf = false
    },
    pdferr(errurl) {

      console.log("出现问题了", errurl)
    },
    openpdf() {
      this.isshowpdf = true
    },

    resumeRowClick(item) {
      console.log("点击当前行: ", item.id);
      // 然后获取当前这里的id, 请求日志记录并保存和渲染
    },
    /** 查询HR简历列表 */
    getList() {
      this.loading = true;
      this.queryParams.queryType = this.$props.type;
      listResume(this.queryParams).then(response => {
        this.resumeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    cancelCheck() {
      this.dialogCheckVisible = false;
      this.resetCheckForm()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        education: null,
        phone: null,
        email: null,
        job: null,
        ruserIds: null,
        source: null,
        sourceRemarks: null,
        area: null,
        resumeUrl: null,
        remarks: null,
        status: null,
        createTime: null,
        updateTime: null,
        backgroundStatus: null,
        entrant: null,
        resumeEvaluator: null,
        hiringApprover: null,
      };
      this.resetForm("form");
    },
    resetCheckForm() {
      this.checkForm = {
        status: null,
        advice: null,
        checkType: null,
        resumeIds: null,
      };
      this.resetForm("checkForm");
    },
    resetDispatchForm() {
      this.dispatchForm = {
        userIds: null,
        resumeIds: null,
      };
      this.resetForm("dispatchForm");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加HR简历";
      this.getUserList();
    },
    /** 添加黑名单 */
    handleBlackPosition(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认添加黑名单,HR简历编号为"' + ids + '"的数据项？').then(function () {
        return addBlack(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("添加成功");
      }).catch(() => { });
    },
    /** 添加人才库 */
    handleAbilityPosition(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认添加人才库,HR简历编号为"' + ids + '"的数据项？').then(function () {
        return addAbility(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("添加成功");
      }).catch(() => { });
    },
    /** 添加无效库 */
    handleFailurePosition(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认添加无效库,HR简历编号为"' + ids + '"的数据项？').then(function () {
        return addFailure(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("添加成功");
      }).catch(() => { });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.getUserList();
      const id = row.id || this.ids
      getResume(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改HR简历";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateResume(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addResume(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除HR简历编号为"' + ids + '"的数据项？').then(function () {
        return delResume(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('hr/resume/export', {
        ...this.queryParams
      }, `resume_${new Date().getTime()}.xlsx`)
    },

    /** 点击审核 */
    clickCheck1(row) {
      this.dialogCheckVisible = true;
      this.checkType = 1;
      this.checkTitle = "审核简历";
    },
    clickCheck2(row) {
      this.dialogCheckVisible = true;
      this.checkType = 2;
      this.checkTitle = "录用审核简历";
    },

    handleCheckForm() {
      // TODO 后续可以为表单添加校验
      this.checkForm.checkType = this.checkType;
      this.checkForm.resumeIds = this.ids;
      console.log(this.checkForm);
      console.log(this.ids);
      // 调用接口就行了，不用判断
      doCheck(this.checkForm).then((response) => {
        this.$modal.msgSuccess("审核成功");
        this.dialogCheckVisible = false;
        this.getList();
      });
    },
    /**点击分配 */
    clickDispatch() {
      this.resetDispatchForm();
      this.dialogDispatchVisible = true;
      this.getUserList();
    },
    handleDispatchForm() {
      // TODO 后续可以为表单添加校验
      this.dispatchForm.resumeIds = this.ids;
      // 调用接口就行了，不用判断
      doDispatch(this.dispatchForm).then((response) => {
        this.$modal.msgSuccess("分配成功");
        this.dialogDispatchVisible = false;
        this.getList();
      });
    },
    cancelDispatch() {
      this.resetDispatchForm();
      this.dialogDispatchVisible = false;
    },
    /** 入职 */
    doInduction() {
      doInduction(this.ids).then((response) => {
        this.$modal.msgSuccess("入职成功");
        this.getList();
      });
    },
    /** 取消入职 */
    cancelInduction() {
      cancelInduction(this.ids).then((response) => {
        this.$modal.msgSuccess("取消入职成功");
        this.getList();
      });
    },
    handleSendOffer() {
      sendOffer(this.ids).then((response) => {
        this.$modal.msgSuccess("发送成功");
        this.getList();
      });
    },

    /**
     * 简历预览
     */
    resumePrev(e, row) {
      e.stopPropagation(); // 阻止事件冒泡  
      this.resumePrevUrl = row.resumeUrl;
      console.log(row.resumeUrl);
      // this.dialogResumePrevVisible = true;

    },

    getBgStatus(status) {
      return (status).split(",")[2];
    },
    clickBgCheck(event, row) {
      event.stopPropagation(); // 阻止事件冒泡  
      // 这里是你的点击事件逻辑
      const bgStatus = this.getBgStatus(row.status);
      if (bgStatus == "0") {
        // 尚未背调, 需要展开背调
        this.$modal.confirm("是否展开背调: " + row.name).then(function () {
          // 发送请求开展背调, 根据当前的背调状态来选择是需要上传背调文件还是什么
          console.log("展开背调")
          bgCheckStart(row.id);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("开展背调成功");
        }).catch(() => { });
      } else if (bgStatus == "1") {
        // 背调已经展开
        // 需要上传背调文件
        this.dialogbgSubmitVisible = true;
        this.bgForm.resumeId = row.id;
      }
    },
    handleBgSubmitForm() {
      // 发送请求, 提交背调材料
      bgCheckSubmit(this.bgForm).then(res => {
        this.$modal.msgSuccess("提交成功");
        this.bgFormReset();
        this.dialogbgSubmitVisible = false;
        // 刷新列表
        this.getList();
      });

    },
    cancelBgSubmit() {
      this.dialogbgSubmitVisible = false;
      this.bgFormReset();
    },
  }
};
</script>
<style scoped>
.custom-tag-size {
  cursor: pointer;
  font-size: 10px;
  padding: 2px 2px;
  height: auto;
  line-height: auto;
  text-align: center;
}

.timeline-card .subtle-text {
  color: #87CEEB;
  /* 淡蓝色 */
  font-size: 14px;
  /* 稍微小一点的字体大小 */
}
</style>